<template>
  <div class="selectStudent">
    <div class="selectTxt">请选择学生</div>
    <div class="select">
      <div
        @click="showDataList"
        :class="{showActive: listShow}"
        class="selectContent"
      >
        <div class="current">{{currentSelect.studentName || '学生名'}}</div>
        <div
          class="arrow"
          :class="{blueArr: listShow}"
        ></div>
      </div>

      <div
        v-if="listShow"
        class="content"
        @click="showDataList"
      >
        <div
          class="listStudent"
          @click="stopPro"
        >
          <div
            v-for="item in dataList"
            :class="{selected : currentSelect.studentId == item.studentId}"
            @click="selected(item)"
          >
            {{item.studentName}}
          </div>
        </div>

      </div>
    </div>
  </div>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
  data() {
    return {
      listShow: false
    }
  },
  props: {
    dataList: {
      type: Array,
      default: () => []
    },
    currentSelect: {
      type: Object,
      default: ()=>{}
    },
    listType: {
      type: String,
      default: ''
    }
  },
  created() {},
  methods: {
    ...mapActions({
      changeCurrentStudent: 'changeCurrentStudent'
    }),
    stopPro(e) {
      e.stopPropagation()
    },
    showDataList() {
      this.listShow = !this.listShow
    },
    selected(item) {
      this.listShow = false
      this.changeCurrentStudent(item)
      this.$emit('changeSelect', item)
    }
  }
}
</script>
<style lang="less" scoped>
.select {
  font-size: 28px;
  position: relative;
}
.selectContent {
  padding: 10px 0 10px 60px;
}
.current {
  display: inline-block;
}
.arrow {
  display: inline-block;
  margin-left: 10px;
  width: 30px;
  height: 18px;
  background: url('../../assets/img/home/litArrDown.png') no-repeat;
  background-size: 100%;
  vertical-align: middle;
  position: relative;
}
.blueArr {
  background: url('../../assets/img/home/blueArr.png') no-repeat;
  background-size: 100%;
}
.content {
  background: rgba(0, 0, 0, 0.6);
  position: fixed;
  z-index: 9;
  width: 100%;
  height: 100%;
  top: 206px;
  left: 0;
}
.listStudent {
  background: #fff;
  padding: 30px 30px 10px 30px;
  > div {
    display: inline-block;
    margin-right: 12px;
    margin-bottom: 20px;
    width: 160px;
    height: 84px;
    line-height: 84px;
    text-align: center;
    background: #f6f6f6;
    border-radius: 3px;
    color: #383838;
  }
}
.selected {
  background: #3271f1 !important;
  color: #fff !important;
}
.showActive {
  color: #3271f1 !important;
}
.selectStudent {
  width: 100%;
  height: 96px;
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
}
.selectTxt {
  font-size: 28px;
}
</style>

